home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0047_Change Foreground-Background Colors.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-24  |  1.5 KB  |  66 lines

  1.  
  2. {
  3.  
  4. This program will place a new foreground and background color and
  5. pattern on the desktop.  It will also set the character that is
  6. displayed for the pattern.
  7.  
  8. This example: the $05 defines the 0 for black foreground and
  9. the 5 for purple background.
  10.  
  11. }
  12.  
  13. program ColorManipulation;
  14.  
  15. uses
  16.     Dos, Objects, Drivers, Memory, Views,
  17.     Menus, Dialogs, App;
  18. type
  19.   PMyBack = ^TMyBack;
  20.   TMyBack = object(TBackground)
  21.     constructor Init(var Bounds: TRect);
  22.   end;
  23.  
  24.   PMyApp = ^TMyApp;
  25.   TMyApp = object(TApplication)
  26.     MyBack: PMyBack;
  27.     constructor Init;
  28.     function GetPalette:PPalette; virtual;
  29.   end;
  30.  
  31. function TMyApp.GetPalette: PPalette;
  32. const
  33.   MyBackColor : TPalette = CColor;  { sets palette to CColor }
  34.                                     { items }
  35. begin
  36.   MyBackColor[1]:=#$05;   { TBackGround Color Constant's first }
  37.                           { number is background and second is }
  38.                           { foreground }
  39.   GetPalette := @MyBackColor;
  40. end;
  41.  
  42. constructor TMyBack.Init(var Bounds: TRect);
  43. begin
  44.   TBackground.Init(Bounds, '▓');{ places ASCII 178 char as    }
  45.                                 { pattern for text on desktop }
  46. end;
  47.  
  48. constructor TMyApp.Init;
  49. var
  50.   R:TRect;
  51. begin
  52.   TApplication.Init;
  53.   GetExtent(R);
  54.   MyBack:= New(PMyBack, init(R));
  55.   Desktop^.Background:= MyBack;
  56.   Desktop^.Insert(Desktop^.Background);
  57. end;
  58.  
  59. var
  60.   TheApp: TMyApp;
  61. begin
  62.   TheApp.Init;
  63.   TheApp.Run;
  64.   TheApp.Done;
  65. end.
  66.